package com.lwq.imserver.model;

import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.apache.commons.lang3.StringUtils;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2022/1/17 17:23
 */
public class HeartBeats {

    public static final String PONG = "PONG";

    public static final String PING = "PING";

    /**
     * 返回公用的心跳内容.
     */
    public static TextWebSocketFrame heartbeatContent() {
        Unpooled.buffer().retain();
        return new TextWebSocketFrame(PONG);
    }

    public static Boolean isPing(String ping){
        return StringUtils.isEmpty(ping) ? false : ping.equals(PING);
    }
}
